/**
 * Created on Tue Mar 19 22:30:26 CST 2013
 * Copyright SinoBest, 2010-2011, All rights reserved.
 */package cn.com.scau.tstjxt.dao;

import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.com.scau.tstjxt.dao.Tdcwj;


/**
 * @Author Sinobest
 * @Date Tue Mar 19 22:30:26 CST 2013
 * @to-do 
 */public class TdcwjDAO extends HibernateDaoSupport {
	
	private static final Log log = LogFactory.getLog(TdcwjDAO.class);
	
	// property constants
	public static final String SYSTEMID = "systemid";
	public static final String LOG_ID = "logId";
	public static final String DCWJWT = "dcwjwt";
	public static final String DCWJWTCN = "dcwjwtcn";
	public static final String DCWJWTDA = "dcwjwtda";
	public static final String DCWJWTDACN = "dcwjwtdacn";
	public static final String RESERVATION01 = "reservation01";
	public static final String RESERVATION02 = "reservation02";
	public static final String RESERVATION03 = "reservation03";
	public static final String RESERVATION04 = "reservation04";
	public static final String RESERVATION05 = "reservation05";
	public static final String RESERVATION06 = "reservation06";
	public static final String RESERVATION07 = "reservation07";
	public static final String RESERVATION08 = "reservation08";
	public static final String RESERVATION09 = "reservation09";
	public static final String RESERVATION10 = "reservation10";
	public static final String RESERVATION11 = "reservation11";
	public static final String RESERVATION12 = "reservation12";
	public static final String RESERVATION13 = "reservation13";
	public static final String RESERVATION14 = "reservation14";
	public static final String RESERVATION15 = "reservation15";
	
	// property constants
	protected void initDao() {
		// do nothing
	}
	
	public void save(Tdcwj transientInstance) {
		log.debug("saving Tdcwj instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public void delete(Tdcwj persistentInstance) {
		log.debug("deleting Tdcwj instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public Tdcwj findById(java.lang.String id) {
		log.debug("getting Tdcwj instance with id: " + id);
		try {
			Tdcwj instance = (Tdcwj) getHibernateTemplate().get(
					"cn.com.scau.tstjxt.dao.Tdcwj", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public List findAll() {
		log.debug("finding all Tdcwj instances");
		try {
			String queryString = "from Tdcwj";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public Tdcwj merge(Tdcwj detachedInstance) {
		log.debug("merging Tdcwj instance");
		try {
			Tdcwj result = (Tdcwj) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void attachDirty(Tdcwj instance) {
		log.debug("attaching dirty Tdcwj instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Tdcwj instance) {
		log.debug("attaching clean Tdcwj instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static TdcwjDAO getFromApplicationContext(ApplicationContext ctx) {
		return (TdcwjDAO) ctx.getBean("TdcwjDAO");
	}
	
	public List findByExample(Tdcwj instance) {
		log.debug("finding Tdcwj instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: " + results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}
	
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Tdcwj instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Tdcwj as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public List findBySystemid(Object systemid) {
		return findByProperty(SYSTEMID, systemid);
	}
	public List findByLogId(Object logId) {
		return findByProperty(LOG_ID, logId);
	}
	public List findByDcwjwt(Object dcwjwt) {
		return findByProperty(DCWJWT, dcwjwt);
	}
	public List findByDcwjwtcn(Object dcwjwtcn) {
		return findByProperty(DCWJWTCN, dcwjwtcn);
	}
	public List findByDcwjwtda(Object dcwjwtda) {
		return findByProperty(DCWJWTDA, dcwjwtda);
	}
	public List findByDcwjwtdacn(Object dcwjwtdacn) {
		return findByProperty(DCWJWTDACN, dcwjwtdacn);
	}
	public List findByReservation01(Object reservation01) {
		return findByProperty(RESERVATION01, reservation01);
	}
	public List findByReservation02(Object reservation02) {
		return findByProperty(RESERVATION02, reservation02);
	}
	public List findByReservation03(Object reservation03) {
		return findByProperty(RESERVATION03, reservation03);
	}
	public List findByReservation04(Object reservation04) {
		return findByProperty(RESERVATION04, reservation04);
	}
	public List findByReservation05(Object reservation05) {
		return findByProperty(RESERVATION05, reservation05);
	}
	public List findByReservation06(Object reservation06) {
		return findByProperty(RESERVATION06, reservation06);
	}
	public List findByReservation07(Object reservation07) {
		return findByProperty(RESERVATION07, reservation07);
	}
	public List findByReservation08(Object reservation08) {
		return findByProperty(RESERVATION08, reservation08);
	}
	public List findByReservation09(Object reservation09) {
		return findByProperty(RESERVATION09, reservation09);
	}
	public List findByReservation10(Object reservation10) {
		return findByProperty(RESERVATION10, reservation10);
	}
	public List findByReservation11(Object reservation11) {
		return findByProperty(RESERVATION11, reservation11);
	}
	public List findByReservation12(Object reservation12) {
		return findByProperty(RESERVATION12, reservation12);
	}
	public List findByReservation13(Object reservation13) {
		return findByProperty(RESERVATION13, reservation13);
	}
	public List findByReservation14(Object reservation14) {
		return findByProperty(RESERVATION14, reservation14);
	}
	public List findByReservation15(Object reservation15) {
		return findByProperty(RESERVATION15, reservation15);
	}

}